#include "mainwindow.h"
#include <QTextEdit>
#include <QMdiSubWindow>
#include <QMdiArea>
#include <QAction>
#include <QToolBar>
#include "osgwidget.h"
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
{
    mdiArea = new QMdiArea;
    mdiArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
    mdiArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
    setCentralWidget(mdiArea);

    QToolBar *fileToolBar = addToolBar(tr("File"));

    const QIcon newIcon = QIcon::fromTheme("document-new", QIcon(":/new_slide.png"));
    newAct = new QAction(newIcon, tr("&New"), this);
    newAct->setShortcuts(QKeySequence::New);
    newAct->setStatusTip(tr("Create a new file"));
    connect(newAct, &QAction::triggered, this, &MainWindow::newMdi);
    fileToolBar->addAction(newAct);


}

MainWindow::~MainWindow()
{

}
void MainWindow::newMdi()
{
    //QTextEdit *child = new QTextEdit();
    osgWidget* child = new osgWidget;
    mdi = new QMdiSubWindow;
    mdi->setWindowTitle("test");
    mdi->setWidget(child);
    mdi->setAttribute(Qt::WA_DeleteOnClose);
    mdi->resize(400,400);
    mdiArea->addSubWindow(mdi);
    mdi->show();     //在非构造函数不加show()，不显示
}
